跳到主要内容

12.旅鼠3

参见:Lemmings1和Lemmings2。

除了行走和坠落之外,Lemmings有时还可以被命令去做一些有用的事情,比如挖掘(当dig=1时,它开始挖掘)。Lemming只有在当前正走在地面上(ground=1且没有坠落)时才能挖掘,并且会一直挖掘直到挖通到另一边(ground=0)。到达那一点后,因为没有地面支撑,它会坠落(啊!),然后一旦再次触地,就会继续以它原来的方向行走。与坠落时相同,挖掘时被碰撞不会产生影响,并且在坠落中或没有地面时被命令挖掘也会被忽略。

(换句话说,行走中的Lemming可以坠落、挖掘或切换方向。如果满足多个这些条件,坠落的优先级高于挖掘,挖掘的优先级又高于切换方向。) 请扩展你的有限状态机以模拟这种行为。

alt text

参见:Lemmings4。

模块声明

module top_module(
input clk,
input areset, // Freshly brainwashed Lemmings walk left.
input bump_left,
input bump_right,
input ground,
input dig,
output walk_left,
output walk_right,
output aaah,
output digging );

做题区